/**
 * \class Coord
 * \brief This is a user interface for space to make the use of spaces simpler.
 * \version 0.3.3
 *
 * \author Woo-Hyun Kim (woorung@nhncorp.com, woorung@gmail.com)
 * \author http://blog.naver.com/wisereign .
 *
 * \date 2008/5/15
 */
//-----------------------------------------------------------------
#ifndef CoordH
#define CoordH
//-----------------------------------------------------------------
#include <iostream>

#include "property/CProperty.h"
#include "CWorkSpaces.h"
//-----------------------------------------------------------------
#define DEFAULT_CONFIG_FILE "coord.conf"
//-----------------------------------------------------------------
using namespace std;
//-----------------------------------------------------------------
class Coord
{
private:
	string host;
	int port;

	CWorkSpaces *wspace;

	bool _alive;

protected:
	void get_access_point(char *conf);
	
public:
	Coord();
	Coord(char *name);
	Coord(char *name, char *conf);
	virtual ~Coord();

	void service(char *s);
	const char *service();
	void instance(char *i);
	const char *instance();
	CDHT *topology();

	bool alive();

	int bulk(int limit);
	int flush();
	long size();
	void autoclean(bool is_clean);
	int clean(string &key);
	int cleanup();

	int write(pair<string,string> &kv);
	int read(pair<string,string> &kv);
	int readIfExists(pair<string,string> &kv);
	int take(pair<string,string> &kv);
	int takeIfExists(pair<string,string> &kv);
};
//-----------------------------------------------------------------
#endif
